﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;

namespace GrayParrot.Web.Controls
{
    public class ValidationConfig
    {
        private const string DEFAULT_FORM_NAME = "formlyForm";

        private string m_message = string.Empty;
        private string m_formId = string.Empty;

        /// <summary>
        /// Gets or sets the form identifier...
        /// </summary>
        /// <value>
        /// The form identifier.
        /// </value>
        /// <remarks>
        /// Usually the form id is "formlyForm" to indicate the standard form created by AngularJS-Formly.
        /// In the case of different form, this property let define the form id so the validation is applied on the control in this specific form
        /// </remarks>
        public string FormId
        {
            get { return m_formId; }
            set 
            {
                m_formId = value;

                if (string.IsNullOrWhiteSpace(value))
                {
                    m_formId = DEFAULT_FORM_NAME;
                }
            }
        }

        /// <summary>
        /// Gets or sets the message show in case of validation error...
        /// </summary>
        /// <value>
        /// The message.
        /// </value>
        public string Message
        {
            get 
            {
                if (m_message == string.Empty) m_message = "Attenzione: Parametri mancanti !!";
            
                return m_message; 
            }
            set { m_message = value; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public List<ValidationParameter> ValidationParameters { get; set; }

        public ValidationConfig()
        {
        }
    }
}
